package ui.activity.profit.biz;

import base.BaseBiz;
import base.BaseResp;
import coom.BaseSubscribe;
import coom.RetrofitHelp;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import ui.model.IntegralBean;
import ui.model.SignBean;

/**
 * Created by chenjian on 19/2/26.
 * 1
 */

public class SignBiz extends BaseBiz {

    /**
     * 获取签到信息
     */
    public void getSignInfo(String customId, Integer year, Integer month, final Callback<SignBean> callback) {
        com.add(RetrofitHelp.getSecretApi().sign(customId, year, month)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<SignBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((SignBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((SignBean) obj);
                    }
                })
        );
    }


    /**
     * 签到信息
     */
    public void signIn(String url, final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().signIn(url)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }


    /**
     * 获取积分信息
     */
    public void getIntegral(String customId, final Callback<IntegralBean> callback) {
        com.add(RetrofitHelp.getSecretApi().integral(customId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<IntegralBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((IntegralBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((IntegralBean) obj);
                    }
                })
        );
    }


}
